package ltd.smallwang.client.task.dto;

import jakarta.validation.constraints.Size;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/**
 * @author justd
 * @description 功能描述
 * @since 2024-05-18 20:37
 **/
@Data
public class TaskExecuteRecordQry {

  @Size(max = 32)
  private String startTimeStr;

  @Size(max = 32)
  private String endTimeStr;

  public LocalDateTime getStartTime() {
    try {
      return LocalDateTime.parse(startTimeStr, DateTimeFormatter.ISO_DATE_TIME);
    } catch (DateTimeParseException exception) {
      return null;
    }
  }

  public LocalDateTime getEndTime() {
    try {
      return LocalDateTime.parse(endTimeStr, DateTimeFormatter.ISO_DATE_TIME);
    } catch (DateTimeParseException exception) {
      return null;
    }
  }
}
